package vn.edu.saigontech.ncms.web.teacher;

import vn.edu.saigontech.ncms.util.Checker;
import vn.edu.saigontech.ncms.web.AbstractValidator;

@SuppressWarnings("serial")
public class ValidateOfferingCheckingAction extends AbstractValidator {
	
	private String date;
	private String startTime;
	private String endTime;
	private Long teacherId;

	public String check() {
		if(Checker.isEmpty(this.date)) {
			this.sendKeyError("validator.required", "date");
		}
		if(!Checker.isDate(this.date, this.i18n("format.date"))) {
			this.sendKeyError("validator.mask", "date", "format.date");
		}	
		if(Checker.isEmpty(this.startTime)) {
			this.sendKeyError("validator.required", "in");
		}
		if(!Checker.isDate(this.startTime, this.i18n("format.time"))) {
			this.sendKeyError("validator.mask", "in", "format.time");
		}
		if(Checker.isEmpty(this.endTime)) {
			this.sendKeyError("validator.required", "out");
		}
		if(!Checker.isDate(this.endTime, this.i18n("format.time"))) {
			this.sendKeyError("validator.mask", "out", "format.time");
		}
		if(Checker.isNull(this.teacherId)) {
			this.sendKeyError("validator.required", "teacher");
		}
		return this.toSuccess();
	}

	public void setDate(String date) {
		this.date = date;
	}

	public void setStartTime(String startTime) {
		this.startTime = startTime;
	}

	public void setEndTime(String endTime) {
		this.endTime = endTime;
	}

	public void setTeacherId(Long teacherId) {
		this.teacherId = teacherId;
	}
}
